<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.7/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>批量添加评论</title>
<style type="text/css">
    .uploader-blank{padding-top: 15px; width:158px;}
    .uploader-list{margin-bottom: 10px; position: relative;}
    .uploader-list img{height: 112px; width: 145px; border:#ccc 1px solid; padding: 5px;}

    /*附件列表*/
    .fujian{display: inline-block; width: auto;}
    .fujian li{list-style: none;  float: left; margin-right: 30px; position: relative; }
    .fujian li img{height: 100px;
    width: 100px;
    border: #ccc 1px solid;
    padding: 3px;}
    .fujian li i{ font-size: 22px;
    position: absolute;
    cursor: pointer;
    right: -7px;
    top: -12px;}
    .fujian li p{font-size: 12px; margin-left: 3px; line-height: 30px;}
    .fujianadd{
            font-size: 100px;
    float: left;
    line-height: 92px;
    }
        

    #autocomplate{
        position: absolute; top: 40px; width: 100%; border-radius: 5px; 
        display: none; background-color: #ddd; z-index: 1000; 
    }
    #autocomplate li{list-style: none; border-bottom: #fff 1px dashed; line-height: 35px; padding:0px 5px; cursor: pointer;}
    #autocomplate li:active{background-color: #fff; color: #333;}
    #autocomplate li:hover{background-color: #fff; color: #333;}
    #shoplist span{ padding: 3px 5px; border:#f37b1d 1px solid; border-radius: 3px; margin-right: 5px; color: #f37b1d; font-size: 12px; cursor:pointer;}
</style>
</head>
<body>
<div class="pd-20">
  <form action="" method="post" class="form form-horizontal" name="form1" id="form1">
    <div class="row cl">

        <label class="form-label col-3"><span class="c-red">*</span>评论数目：</label>
        <div class="formControls col-6 s-msg">
            <input type="text" class="input-text" placeholder="评论数目" id="total" name="total" nullmsg="评论名称不能为空！" datatype="n1-16">
        </div>
        <div class="col-2"> </div>
    </div>
   
    <div class="row cl">
        <label class="form-label col-3"><span class="c-red">*</span>选择产品：</label>
        <div class="formControls col-6" style="position: relative;">
            <input type="text" class="input-text" value="" placeholder="" id="goods_name" onfocus="opensearch()" onblur="setTimeout(closesearch,200)" autocomplete="off" nullmsg="请选择评论商品！">
            <input type="hidden" name="gid" id="gid">
            <div id="autocomplate" class="thinklist">
                
            </div>
        </div>
    </div>
    
    
   
    <div class="row cl">
        <div class="col-9 col-offset-3">
            <input class="btn btn-primary radius" type="submit" id="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
        </div>
    </div>
    </form>
</div>
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 

<script type="text/javascript" src="lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="lib/layer/2.1/layer.js"></script>
<script type="text/javascript" src="js/H-ui.js"></script> 
<script type="text/javascript" src="js/H-ui.admin.js"></script>
<script type="text/javascript" src="js/s.js"></script> 
<script type="text/javascript" src="lib/daterangepicker/moment.min.js"></script> 
<script type="text/javascript" src="lib/daterangepicker/jquery.daterangepicker.js"></script>
<link rel="stylesheet" href="lib/daterangepicker/daterangepicker.css" /> 
<script type="text/javascript">
var prevKeywordVal;
var intervalId;


// 商家列表联想搜索
function autocomplate(){
    var input=$("#goods_name");
    if(window.prevKeywordVal === $(input).val() || $(input).val()==''){
        return false;
    }
    var html='';
    var api=API_GOODS+'?t=1&k='+$(input).val();
    var autocomplate='#autocomplate';
    $.getJSON(api,function(data){
        if(!checkStatus(data)) return;
        $(autocomplate).show().html('');
        for (x in data.datas){
            html+="<li data-name="+data.datas[x].goods_name+" data-id="+data.datas[x].goods_id+">"+data.datas[x].goods_id+": "+data.datas[x].goods_name+"(销量:"+data.datas[x].goods_sales+")</li>";
        }
        $(autocomplate).html(html);
    }); 
    if($(input).val()!==''){
        prevKeywordVal=$(input).val(); 
    }
}

// 打开搜索列表
function opensearch() {
    $('#autocomplate').show();
    var html='';
    $.getJSON(API_GOODS+'?t=1',function(data){
        for (x in data.datas){
            html+="<li data-name="+data.datas[x].goods_name+" data-id="+data.datas[x].goods_id+">"+data.datas[x].goods_id+": "+data.datas[x].goods_name+"(销量:"+data.datas[x].goods_sales+")</li>";
        }
        $('#autocomplate').html(html);
    })
    intervalId=setInterval('autocomplate()',500);
}
// 关闭搜索框
function closesearch(){
    $('#autocomplate').hide();
    clearInterval(intervalId);

}


$(function(){
    // 选择评论商品
    $(document).on('click','#autocomplate li',function(){
        var id=$(this).data("id");
        var name=$(this).data("name");

        $("#goods_name").val('id:'+id+' '+name);
        $("input[name=gid]").val(id);
    
    })
    

    var editid=getUrlParam('editid');//编辑评论id
    $("#form1").attr("action", API_EVALUTEADDGROUP);







    if(editid!=null){
        
        var eidturl=API_EVALUTEADDGROUP+"?aid="+editid;

        $.getJSON(eidturl,function(data){
            if(!checkStatus(data)) return;//判断登录

            if(data.datas==''){
                layer.msg("数据加载错误", {icon:2,time:1000});
            }else{
                $("#total").val(data.datas.total);
                $("#goods_name").val(data.datas.goods_name);
                
                $("#gid").val(data.datas.gid);
                
               

                $("#form1").attr("action", eidturl);

            }
            
        })
    }


    Validformsubmit("#form1");
});

// 移除选中的图片
function fj_close(obj){
    $(obj).parents("li").remove();
}

</script>
</body>
</html>